package md.lanjing.com.module_mine.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lxh.baselibray.base.XActivity;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.view.TitleView;

import butterknife.BindView;
import butterknife.OnClick;
import md.lanjing.com.module_mine.R;
import md.lanjing.com.module_mine.R2;

import com.lxh.baselibray.constant.Constant;


public class LookReceiveMoneyTypeActivity extends XActivity {
    public static final String TYPE  ="type";
    @BindView(R2.id.titleView)
    TitleView titleView;
    @BindView(R2.id.iv_pay_code)
    ImageView ivPayCode;
    @BindView(R2.id.tv_card_name)
    TextView tvCardName;
    @BindView(R2.id.tv_card_num)
    TextView tvCardNum;
    @BindView(R2.id.tv_consign_name)
    TextView tvConsignName;
    @BindView(R2.id.linear_bank_pay)
    LinearLayout linearBankPay;
    @BindView(R2.id.btn_modify)
    Button btnModify;


    int type=-1;
    private String aliPngCode;
    private String weixinPngCode;
    private String bankNumber;
    private String bankName;
    private String cardOwner;
    @Override
    public void initData(Bundle savedInstanceState) {

        aliPngCode= SPUtils.getString(Constant.ALI_PNG,null,context);
        weixinPngCode= SPUtils.getString(Constant.WEIXIN_PNG,null,context);
        bankNumber= SPUtils.getString(Constant.BANK_NUMBER,null,context);
        bankName= SPUtils.getString(Constant.BANK_NAME,null,context);
        cardOwner= SPUtils.getString(Constant.BANK_OWNER,null,context);

        type = getIntent().getIntExtra(TYPE,0);
        switch (type){
            case 0:
                ivPayCode.setVisibility(View.VISIBLE);
                linearBankPay.setVisibility(View.GONE);
                Glide.with(context).load(ServiceGenerator.BASE_URL+":8089/image/"+aliPngCode).into(ivPayCode);
                break;
            case 1:
                ivPayCode.setVisibility(View.VISIBLE);
                linearBankPay.setVisibility(View.GONE);
                Glide.with(context).load(ServiceGenerator.BASE_URL+":8089/image/"+weixinPngCode).into(ivPayCode);
                break;
            case 2:
                ivPayCode.setVisibility(View.GONE);
                linearBankPay.setVisibility(View.VISIBLE);
                tvCardName.setText(bankName);
                tvCardNum.setText(bankNumber);
                tvConsignName.setText("持卡人姓名:"+cardOwner);
                break;
        }




    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_look_receive_money_typel;
    }



    @OnClick(R2.id.btn_modify)
    public void onViewClicked() {
        Intent intent = new Intent(this, UpReceiveMoneyTypeActivity.class);
        intent.putExtra(UpReceiveMoneyTypeActivity.TYPE,type);
        startActivity(intent);
    }
}
